<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('项目设计工作联系函列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="projectName"/>
                            </li>
                            <li>
                                <label>函件编号：</label>
                                <input type="text" name="funNo"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="gcgl:fun:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="gcgl:fun:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:fun:edit')}]];
        var removeFlag = [[${@permission.hasPermi('gcgl:fun:remove')}]];
        var prefix = ctx + "sj/fun";
        var datasstatus = [[${@dict.getType('sj_contract_status')}]];
        var datasfun = [[${@dict.getType('sj_funType')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "项目设计工作联系函",
                sortName: "id desc",
                sortOrder: "",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'gcProjectid',
                    title: '合同ID',
                    visible: false
                },
                {
                    field: 'projectName',
                    title: '项目名称'
                },
                {
                    field: 'clientName',
                    title: '建设单位'
                },
                {
                    field: 'orderNo',
                    title: '工程编号',
                    visible: false
                },
                {
                    field: 'funNo',
                    title: '函件编号'
                },
                {
                    field: 'sender',
                    title: '发送人'
                },
                {
                    field: 'sendAt',
                    title: '发送时间'
                },
                {
                    field: 'fzr',
                    title: '项目负责人'
                },
                {
                    field: 'spr',
                    title: '审核人'
                },
                {
                    field: 'type',
                    title: '函件类型',
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datasfun, item.type);
		            }
                },
                {
                    field: 'status',
                    title: '状态',
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datasstatus, item.status);
		            }
                },
                {
                    field: 'hfunfile',
                    title: '资料文件',
		            formatter: function(value, item, index) {
		            	let zilwjlink = "";
		            	
		            	if(item.hfunfile!=null){
		            		var n=item.hfunfile.split(",");
			            	for(var i=0;i<n.length;i++){
//			             		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
			            		var url = n[i];
			            		if(url==""){
			            			zilwjlink+="<a href='"+url+"' target='_blank' ></a>";
			            		}else{
			            			zilwjlink+="<a href='"+url+"' target='_blank' >函件下载</a>";
			            		}
			            	}
		            	}
		            	
		            	return zilwjlink;
		            },
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status==0){
                        	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        if(row.status==3 || row.status==8){
                        	actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="uploadFun(\'' + row.id + '\')"><i class="fa fa-edit"></i>上传盖章函件</a> ');
                        }
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="run(\'' + row.processInstanceId + '\')"><i class="fa fa-file-archive-o"></i>流程进度</a>&nbsp;');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="print(\'' + row.id + '\')"><i class="fa fa-download"></i>打印</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function print(id){
            $.modal.openTab('打印',"/sj/fun/funPrint/"+id);
        }
        
        function uploadFun(id){
            $.modal.openTab('上传盖章函件',"/sj/fun/uploadFun/"+id);
        }
        
        function run(processInstanceId) {
            $.modal.open("执行记录", ctx + "flow/monitor/historyDetail?processInstanceId=" + processInstanceId);
        }
        
        function traceProcess(processInstanceId) {
            $.modal.openTab("流程进度", ctx + "flow/monitor/traceProcess/"+processInstanceId);
        }
    </script>
</body>
</html>